// 文字类型

let xo: 'hello' = 'hello'
// x = 'world'

function priintText(s: string, alignment: 'left' | 'right' | 'center') {

}

function compare(a: string, b: string): -1 | 0 | 1 {
  return a === b ? 0 : a > b ? 1 : -1
}

interface Options {
  width: number
}
function configure(x: Options | 'auto') {

}
configure({width: 100})
configure('auto')

let b1: true = true
let b2: false = false

const obj = {
  count: 0
}
if(true) {
  obj.count = 1
}

function handleRequest(url: string, method: 'GET' | 'POST' | 'GUESS') {
  
}

const req = {
  url: 'http://example.com',
  method: 'GET'
}
// handleRequest(req.url, req.method ) // error 会自动推出字符串

handleRequest(req.url, req.method as 'GET')
// or 
const req1 = {
  url: 'http://example.com',
  method: 'GET' as 'GET'
}
// or
const req2 = {
  url: 'http://example.com',
  method: 'GET'
} as const
